
package com.esun.rabbit2.communicaters.sportteryfootballshengfu;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.DistributionChannels;
import com.esun.config.Key;
import com.esun.config.Language;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;


/** 
* @ClassName: SportteryFootballShengfuNormalBuyCommunicater 
* @Description: 足球胜负立即购买接口
* @author: Liujun liuj@500wan.com
* @date: 2012-4-25 上午11:50:34 
*  
*/
public class SportteryFootballShengfuNormalBuyCommunicater extends ServerCommunicater {

	private String msgServer; // 服务器信息
	private boolean isSucceed = false;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}

	public boolean isBuySucceed(int zhushu, int beishu, long allMoney, String codes) throws ClientProtocolException, IOException, ParserConfigurationException,
			SAXException {
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_FOOTBALLSHENGFU_LATEST_LOTTERY_INFO));
		list.add(mapItem(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));
		list.add(mapItem(Key.KEY_CHANNEL, DistributionChannels.QUDAO));
		list.add(mapItem(Key.KEY_LOTID, Config.SHENGFUCAI));
		list.add(mapItem(Key.KEY_ALLMONEY, Long.toString(allMoney)));
		list.add(mapItem(Key.KEY_BEISHU, Integer.toString(beishu)));
		list.add(mapItem(Key.KEY_CODES, codes));
		list.add(mapItem(Key.KEY_TITLE, Language.STR_FUSHI_TITLE));
		list.add(mapItem(Key.KEY_ZHUSHU, Integer.toString(zhushu)));
		list.add(mapItem(Key.KEY_VERSION,UserInfo.getUserInfo().getCurrentVersion()));
		 

		// 写入服务器返回信息
		super.getServerResponse(list, true);
		setMsgServer(super.getErrorMSG());
		if (super.getState() == 100) {
			isSucceed = true;
		} else {
			isSucceed = false;
		}
		return isSucceed;

	}

	/**
	 * @Title: mapItem
	 * @Description: (工具类,用于构建AraayList单条内容)
	 * @param @param name 参数名
	 * @param @param value 参数值
	 * @param @return map
	 * @return HashMap<String,String> 返回类型
	 * @throws
	 */
	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}
}
